const userDAO = require('../dao/userDAO')
const permissionDAO = require('../dao/permissionDAO')

function  login(user,callback) {
    const responseMessage = {
        flag: false,
        user:{}

    }

    userDAO.exists(user,(rows)=>{
        console.log(rows);
        if(rows.userId>0){
            responseMessage.flag=true;
            responseMessage.user = rows;
        }
        callback(responseMessage);
    })

}

function findPermissionsByRoleId(roleId,callback) {

    permissionDAO.selectByRoleId(roleId,(rows)=>{
        callback(rows);
    })
}

module.exports ={
    login,
    findPermissionsByRoleId
}
